<template>
  <div class="bbox">
  </div>
</template>

<script>
export default {
  name: "Login",
  setup() {
    const data = reactive({
      username: "",
      password: "",
    });
    const router = useRouter();
    const handleLogin = async () => {
      try {
        const result = await post("/api/user/login", {
          username: data.username,
          password: data.password,
        });
        if (result?.errno === 0) {
          localStorage.isLogin = true;
          router.push({ name: "Home" });
        } else {
          alert("登陆失败");
        }
      } catch (e) {
        alert("请求失败");
      }
    };
    const handleRegisterClick = () => {
      router.push({ name: "Register" });
    };
    return { handleLogin, handleRegisterClick, data };
  },
};



</script>

